const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const base = require('./webpack.base.js');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractCss = new ExtractTextPlugin('css/style.css');
// const WorkboxPlugin = require('workbox-webpack-plugin');

module.exports = merge(base, {
	mode: 'production',
	devtool: 'source-map',
	module: {
		rules: [
			{
				test: /\.(css|less)$/,
				use: extractCss.extract({
					use: [{
						loader: 'css-loader'
					}, {
						loader: 'less-loader'
					}],
					fallback: 'style-loader'
				})
			},
		]
	},
	plugins: [
		// new WorkboxPlugin.GenerateSW({
		// 	clientsClaim: true,
		// 	skipWaiting: true,
		// }),
		extractCss,
	],
	output: {
		filename: 'js/[name].[chunkhash:7].js',
		path: path.resolve(__dirname, '../dist'),
		publicPath: '',
	}
});